<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------
/**
 * Class Evaluation
 * Desc  评价Model
 * Create on 2024/10/25 17:52
 * Create by wangyafang
 */

namespace app\api\model\wddj\user\evaluation;


use think\Model;

class Evaluation extends Model
{
// 表名
    protected $name = 'wddj_order_evaluation';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    protected static function init()
    {
        self::beforeInsert(function ($row) {
            if (!empty($row['options_ids'])) {
                $optionsIdsArray = explode(',',$row['options_ids']);
                $order = 'weigh desc,id desc';
                $contentArray = (new Options())->where('id','in',$optionsIdsArray)->order($order)->column('content');
                $row->content = implode(',',$contentArray);
            }
        });
    }

    public function getContentAttr($value)
    {
        return explode(',',$value);
    }
}



 